/*
 * SDLApp.h
 *
 *  Created on: 12 jan 2010
 *      Author: Andreas
 */

#ifndef SDLAPP_H_
#define SDLAPP_H_

#include <stdio.h>
#include <string>
#include "SDL/SDL.h"

enum GameStatus {
	STATE_MENU,
	STATE_RUNNING,
	STATE_PAUSED,
	STATE_CONSOLE,
	STATE_MINIMIZED
};

class SDLApp {
public:
	SDLApp(int w, int h, int bpp);
	virtual ~SDLApp();
	bool init_GL();
	void start();
	void clearScreen();

	virtual void init() = 0;
	virtual void handleEvents(SDL_Event *e);
	virtual void handleInput() = 0;
	virtual void update(int elapsed) = 0;
	virtual void draw() = 0;
	virtual void dostring(std::string str) = 0; /* Console usage */
	void SetVSync(bool sync);

	void setStatus(GameStatus s);
	void setQuit(bool q);

protected:
	int lasttime, fpstime;
	int frames;
	int fps;
	int scrw, scrh, scrbpp;
	SDL_Surface *screen;
	bool quit;
	GameStatus status;

};

#endif /* SDLAPP_H_ */
